var connect = require('connect');
var serveStatic = require('serve-static');
var bodyParser = require('body-parser');
const path = require('path');
const FileUtils = require('../utils/fileUtils');

var app = connect();

app.use(bodyParser.json());

app.use('/api/get-page-info', function (req, res) {
  let str = FileUtils.readFile();
  // 为了兼容amis返回的数据结构
  let json = [{ add_data: JSON.parse(str) }];
  res.write(JSON.stringify(json));
  res.end();
});

app.use('/', serveStatic(path.resolve(__dirname, '../render')));
app.use('/debug', serveStatic(path.resolve(__dirname, '../render')));

app.listen(5188);
